package com.shixi.shixitraining.shixitraining.ui.tabhome.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.shixi.shixitraining.shixitraining.ui.tabhome.entity.TrainingListDetailBean;
import com.shixi.shixitraining.shixitraining.ui.tabhome.fragment.BookingInformationFragment;
import com.shixi.shixitraining.shixitraining.ui.tabhome.fragment.FeeDescriptionFragment;
import com.shixi.shixitraining.shixitraining.ui.tabhome.fragment.ProjectFragment;
import com.shixi.shixitraining.shixitraining.ui.tabhome.fragment.ScheduleFragment;

/**
 * Created by shenyan on 2018/8/9.
 */

public class TrainingDetailPagerAdapter extends FragmentPagerAdapter {
    private  String titles[]={"项目亮点","日程安排","费用说明","预定须知"};
    private TrainingListDetailBean bean;
    public TrainingDetailPagerAdapter(FragmentManager fm,TrainingListDetailBean response) {
        super(fm);
        this.bean=response;
    }

    Fragment fragment;

    @Override
    public Fragment getItem(int position) {
        Bundle bundle=new Bundle();
        bundle.putSerializable("bean",bean);
        if (titles[position].equals("项目亮点")){

            fragment=new ProjectFragment();
        }else if (titles[position].equals("日程安排")){
//            bundle.putSerializable("bean",bean);
            fragment=new ScheduleFragment();
        }else if (titles[position].equals("费用说明")){
//            bundle.putSerializable("bean",bean);
            fragment=new FeeDescriptionFragment();
        }else if (titles[position].equals("预定须知")){
//            bundle.putSerializable("bean",bean);
            fragment=new BookingInformationFragment();
        }

        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
